$(function () {
   var pagenum = getParms("page");
    if(pagenum=="")
        getIndexVoByPageNum(1);
    else
        getIndexVoByPageNum(pagenum);

})
function getIndexVoByPageNum(pagenum) {
    $.post({
        url: baseurl+api.index+pagenum,
        success: function (res) {
            if(res.code=="200"){
                var s="";
                $.each(res.data.info,function (index,info) {

                    s+="                <article class=\"post post-type-normal\" style=\"opacity: 1; display: block; transform: translateY(0px);\"><header class=\"post-header\"><h1 class=\"post-title\">\n" +
                        "               <a class=\"post-title-link\" href='/detail/"+info.date+"/"+info.description+"'>"+info.title+"</a></h1><div class=\"post-meta\"><span class=\"post-time\"><span class=\"post-meta-item-icon\"><i class=\"fa fa-calendar-day\"></i></span><span class=\"post-meta-item-text\">发表于</span>\n" +
                        "               <time title=\"创建于\" datetime=\"\">"+info.time+"</time></span><span class=\"post-category\"><span class=\"post-meta-divider\">|</span><span class=\"post-meta-item-icon\"><i class=\"fa fa-folder-open\"></i></span><span class=\"post-meta-item-text\">分类于</span><span>\n" +
                        "               <a href=\"/categories/"+info.categoriesName+"\" rel=\"index\">\n" +
                        "               <span>"+info.categoriesName+"</span></a></span></span><span class=\"post-comments-count\"><span class=\"post-meta-divider\">|</span><span class=\"post-meta-item-icon\"><i class=\"fa fa-comment\"></i></span><a href=\"javascript:void(0)\">\n" +
                        "               <span class=\"post-comments-count disqus-comment-count\" data-disqus-identifier=\"\">"+info.commentsCount+" Comments</span></a></span><span id=\"\" class=\"leancloud_visitors\" data-flag-title=\"\"><span class=\"post-meta-divider\">|</span><span class=\"post-meta-item-icon\"><i class=\"fa fa-eye\"></i></span> <span class=\"post-meta-item-text\">阅读次数</span>\n" +
                        "               <span class=\"leancloud-visitors-count\">"+info.readCount+"</span></span> </div></header>" +
                        "               <div class=\"post-body\" itemprop=\"articleBody\" style=\"opacity: 1; display: block; transform: translateY(0px);\">"+marked(info.content)+"</div>" +
                        "               <div class=\"post-button text-center\">\n" +
                        "               <a class=\"btn\" href='/detail/"+info.date+"/"+info.description+"' rel=\"contents\">阅读全文 »</a></div><footer class=\"post-footer\"><div class=\"post-eof\"></div></footer></article>";
                })
                $("#posts").html(s);
                pageination(res.data,"page");
            }else
                window.location.href="/notfound";
        }
    })
}
function getParms(name) {
    var url= window.location.href;
    var index=url.indexOf(name);
    if(index==-1)
        return "";
    var s = url.substring(index+name.length+1);
    return s;
}